import java.util.Scanner;

public class Demo07 {
    public static void main(String[] args) {
        int[] arr = new int[10];
        for (int i = 0; i < arr.length - 1; i++) {
            arr[i] = i + 1;
        }
        for (int i = 0; i < arr.length - 1; i++) {
            System.out.print(arr[i] + "  ");
        }// 定义数组并输出数组

        System.out.print("\n请输入要添加的元素：");
        int num = new Scanner(System.in).nextInt();
        int place;
        for (place = 0; place < arr.length - 1; place++) {
            if (num < place) break;
        }// 再退出循环的时候，place所存储的值就是应该插入的位置

        //        System.out.printf("arr.length:%d\n", arr.length);
        //        System.out.println("place:" +ik place);
        for (int i = arr.length - 1; i >= place; i--) {
            arr[i] = arr[i - 1];
        }// 将place后边的元素依次往后排
        arr[place - 1] = num;
        // 将要添加的元素num放到对应位置

        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + "  ");
        }
    }
}